
<!DOCTYPE html>
<html ng-app="myapp">
<head>
  <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
  <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
  <title>angular与javascript相互调用</title>
  <script src="angular-1.5.6/angular.js"></script>
</head>
<body>
  <div ng-controller="c2_1">
   执行js表达式：
   <br>
   <input type="text" ng-model="expr1">
   <button ng-click="testExp1(expr1)" type="button" name="button">计算</button>
   <br>
   执行Angular表达式：
   <br>
   <input type="text" ng-model='expr2' name="name" value="">
   <span ng-bind="$eval(expr2)"></span>
  </div>
  <script type="text/javascript">
    var myapp = angular.module('myapp',[]);

    myapp.controller('c2_1',function($scope){
      $scope.expr1 = 20;
      $scope.expr2 = '20+1|number:0';
      $scope.testExp1 = function (expr){
        var newv = parseInt(expr)+1;

        console.log(newv);
      };
    })
  </script>
</body>

</html>
